package com.example.no1admin.search.repo;

import com.example.no1admin.search.entity.RouteForES;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

//SpuForElastic实体类操作es的持久层方法
//继承父接口，实现增删改查
@Repository
public interface RouteForESRepository extends ElasticsearchRepository<RouteForES,Long> {

    @Query("{\n" +
            "    \"bool\": {\n" +
            "      \"should\": [\n" +
            "        { \"match\": { \"name\": \"?0\"}},\n" +
            "        { \"match\": { \"keywords\": \"?0\"}},\n" +
            "        { \"match\": { \"description\": \"?0\"}},\n" +
            "        ]\n" +
            "     }\n" +
            "}")
        // 上面指定了查询语句,这个方法的方法名就随意定义了
    Page<RouteForES> querySearch(String keyword, PageRequest pageRequest);
}
